<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>portal</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
    	<div id="market_top_id"></div>
		
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/?s=Portal.Plugins.GetMarketPlugins', // 换成相应的运营平台接口
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                    "code": res.ret == 200 ? 0 : res.ret, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.items //解析数据列表
                };
            },
            cols: [[
                //{type: "checkbox", width: 50, fixed: "left"},
                {field: 'plugin_key', width: 150, title: '插件编号', sort: true},
                {field: 'plugin_name', minWidth: 300, title: '插件名称'},
                {field: 'plugin_version', width: 120, title: '版本'},
                {field: 'plugin_author', width: 150, title: '开发者'},
                {field: 'plugin_price', width: 120, title: '插件价格', sort: true},
                {
                    field: 'plugin_status', minWidth: 50, align: 'center', templet: function (d) {
                        if (d.plugin_status == 1) {
                            return '<span class="layui-badge layui-bg-green">已安装</span>';
                        } else if (d.plugin_status == 3) {
                            return '<span class="layui-badge layui-bg-red">检测有最新版本</span>';
                        } else if (d.plugin_status == 2) {
                            return '<span class="layui-badge-rim layui-bg-red">已下载，待安装</span>';
                        } else {
                        	return '<span class="layui-badge layui-bg">未安装</span>';
                        }
                    }, title: '插件状态', sort: true
                },
                {field: 'plugin_op', minWidth: 50, title: '操作'}
                //{title: '操作', minWidth: 50, templet: '#currentTableBar', fixed: "right", align: "center"}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true
        });
        
        $.getJSON('/?s=Portal.Plugins.MarketTopContent', function (data) {
        	if (data.ret == 200 && data.data.content) {
        		$("#market_top_id").html(data.data.content);
        	}
        });

    });
</script>
<script>

</script>

</body>
</html>
